namespace TerritoryGame.Domain.ValueObjects;

/// <summary>
/// 游戏时长值对象（秒）
/// </summary>
public record GameDuration
{
    public int Value { get; }
    
    public GameDuration(int value)
    {
        if (value < 60 || value > 600)
            throw new ArgumentException("游戏时长必须在60-600秒之间", nameof(value));
            
        Value = value;
    }
    
    public static implicit operator int(GameDuration duration) => duration.Value;
    
    public TimeSpan ToTimeSpan() => TimeSpan.FromSeconds(Value);
    
    public override string ToString() => $"{Value}秒";
}
